import axios from 'axios';
import Qs from 'qs'
import config from '../config/config';

let util = {

};
util.title = function(title) {
    title = title ? title + ' - 配置中心' : 'iView project';
    window.document.title = title;
};
// const auth='11111'

const ajaxUrl = config[config.env].host;
// const ajaxUrl = env === 'development' ?
//     'http://127.0.0.1:8888' :
//     env === 'production' ?
//     'https://www.url.com' :
//     'https://debug.url.com';
//

util.ajax = axios.create({
  baseURL: ajaxUrl,
  transformRequest: (data) => {
    return Qs.stringify(data)
  },
  headers: {
      // 'Authorization':auth,
      'Content-Type':'application/x-www-form-urlencoded; charset=utf-8'
  },
  timeout: 5000
});
// util.ajax = axios.create({
//     baseURL: ajaxUrl,
//     timeout: 30000
// });

export default util;